package org.flexlancer.databases
{
	import flash.utils.Dictionary;
	
	public class Dishes
	{
		public static const TABLE:String = "dishes";

		public static function Add(itemcode:Number,itemname:String,itemcat:Number,diprice:Number,tayprice:Number,dprice:Number):void{
			try{
				var insertObj:Object = new Object();
				insertObj.itemcode = itemcode;
				insertObj.itemname = itemname;
				insertObj.itemcat = itemcat;
				insertObj.dinein = diprice;
				insertObj.takeaway = tayprice;
				insertObj.delivery = dprice;
				DatabaseManager.Manager.Insert(TABLE,insertObj);
			}catch(err:Error){
				throw err;
			}
		}

		public static function Update(dishid:Number,itemname:String, itemcode:Number, diprice:Number = -1,tayprice:Number = -1,dprice:Number = -1):void{
			try{
				var updateObj:Object = new Object();
				updateObj.itemname = itemname;
				updateObj.itemcode = itemcode;
				updateObj.dinein = diprice;
				updateObj.takeaway = tayprice;
				updateObj.delivery = dprice;
				DatabaseManager.Manager.Update(TABLE,updateObj,"dishid = "+dishid);
			}catch(err:Error){
				throw err;
			}
		}

		public static function List(condition:String = ""):Array{
			try{
				return DatabaseManager.Manager.Select(TABLE,null,condition,"itemcode"); 
			}catch(err:Error){
				throw err;
			}
			return new Array;
		}
		public static function Delete(condition:String = ""):void{
			try{
				DatabaseManager.Manager.Delete(TABLE,condition);
			}catch(err:Error){
				throw err;
			}
		}
	}
}